﻿@using LanDBom.Resources
@{
    ViewBag.Title = "shenpiView";
    Layout = "~/Views/Shared/_Genertals.cshtml";
}
<div id="wid">
    <form class="row padtop col-12">
        <fieldset class="boun">
            <legend class="len">@Resource.String155</legend>
            <div class="row">
                <p class="col">
                    @Html.Label(Resource.String410)
                    @Html.TextBox("shen")
                </p>
                <p class="col">
                    @Html.Label(Resource.String1123)
                    <select id="ming" class="input-au">
                        <option value=""></option>
                        <option value="对外报价">对外报价</option>
                        <option value="核价审批">核价审批</option>
                        <option value="供应商审批">供应商审批</option>
                    </select>
                </p>
                <p class="col">
                    @Html.Label(Resource.String1270)
                    @Html.TextBox("shi")
                </p>
                <p class="col-2">
                    <input type="button" value="@Resource.String155" name="cha" class="btn-secondary btn-sm" />
                </p>
            </div>
        </fieldset>
    </form>
    <div>
        <table class="table tab">
            <thead class="thead-light">
                <tr style="text-align-last:center;">
                    <th scope="col" style="width:50px;">@Resource.String413</th>
                    <th scope="col">@Resource.String414</th>
                    <th scope="col">客户名称</th>
                    <th scope="col">项目名称</th>
                    <th scope="col">@Resource.String418</th>
                    <th scope="col">@Resource.String416</th>
                    <th scope="col">@Resource.String1270</th>
                    <th scope="col">@Resource.String415</th>
                </tr>
            </thead>
            <tbody class="gun" id="BUtain" style="height:570px;">

            </tbody>
        </table>
    </div>
</div>
@section scripts{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
       
        $(function () {
            $("#li11").css({ "color": "black", "background-color": "white" })
            $('input[name="cha"]').click(function () {
                skonf()
            })
            function skonf() {
                var shen = $("#shen").val()
                var shi = $("#shi").val()
                var ming = $("#ming").val()
                var Names = $("#Login_N").text()
                $.ajax({
                    url: '/Admin/shenpiView',
                    type: 'POST',
                    data: { "Namse": Names, "bian": shen, "shunf": shi, "zhunag": ming, "stse": 2 },
                    success: function (date) {
                        console.log(date)
                        createRow(date);
                    },
                    error: function () {
                        alert("错误 请重试！")
                    }
                })
            }
            function createRow(date) {
                $("#BUtain tr").remove();
                var Nmamnd = $("#Login_N").text()
                $.each(date, function (i, item) {
                    var jting = "";
                    var sjinf = "";
                    var sf = "";
                   
                    if (item.FFZ != "通过" && item.FFZ != "驳回" && item.Fzhuang != "结束") {
                        jting = item.Fzhuang;
                        sjinf = "等待" + item.FFirst + "审核";
                        sf = item.FFirst
                    }
                    else if (item.FTZ != "通过" && item.FFZ == "通过" && item.FTZ != "驳回" && item.Fzhuang != "结束") {
                        jting = item.Fzhuang;
                        sjinf = "等待" + item.FTwo + "审核";
                        sf = item.FTwo
                    } else if (item.Fzhuang=="结束") {
                        jting = item.Fzhuang;
                        sjinf = "等待" + item.FTwo + "审核";
                        sf =""
                    }

                    console.log(jting, sjinf, sf)
                    var $tr =
                        (`
                            <tr>
                                <td style="width:50px;">${item.FID}</td>
                                <td id="Dan" style="color:#2a6bcc;">${item.FJINF}</td>
                                <td>${item.FFS}</td>
                                <td>${item.FFive}</td>
                                <td>${item.FMIao}</td>
                                <td>${item.FQsj}</td>
                                <td>${item.FShenR}</td>
                                <td class="">${sjinf}</td>
                            </tr>
                        `);

                    if (sf == $("#Login_sf").text()) {
                        $("#BUtain").append($tr);
                    }
                    
                })

            }

            //显示
            $(function () {
                var Names = $("#Login_sf").text()
                $.ajax({
                    url: '/Admin/shenpiView',
                    type: 'POST',
                    data: { "Namse": Names,  "stse": 1 },
                    success: function (date) {
                        console.log(date)
                        createRow(date);
                    },
                    error: function () {
                        alert("错误 请重试！")
                    }
                })
                $(document).on("click", "#Dan", function () {
                    var bian = $(this).text();
                    var sjinf = $(this).next().next().next().text();
                    if (sjinf == "核价审批") {
                        window.location.href = "/ShenPI/HJSP?bians=" + bian + "&&Njism=" + sjinf;
                    }
                    else if (sjinf =="供应商审核") {
                        window.location.href = "/ShenPI/GysH?bian=" + bian ;
                    }
                    else {
                        window.location.href = "/ShenPI/Duiw?bians=" + bian + "&&Njism=" + sjinf;
                    }
                })
            })
        })
    </script>
}